package com.fansl.allround.common.security.jwt;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.TokenEnhancer;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;

/**
 * @author fansl
 * @Description: TODO
 * @date 2019/9/26 15:16
 */
@Configuration
public class JwtTokenStoreConfig {
    @Autowired
    private AllroundSysUserJwtTokenEnhancerHandler allroundSysUserJwtTokenEnhancerHandler;
    @Bean
    public TokenEnhancer jwtTokenEnhancer(){
        return new AllroundSysUserJwtTokenEnhancer(allroundSysUserJwtTokenEnhancerHandler);
    }
    @Bean
    public TokenStore jwtTokenStore(){
        return new JwtTokenStore(jwtAccessTokenConverter());
    }
    @Bean
    public JwtAccessTokenConverter jwtAccessTokenConverter(){
        JwtAccessTokenConverter jwtAccessTokenConverter = new JwtAccessTokenConverter();
        jwtAccessTokenConverter.setSigningKey("allround");
        return jwtAccessTokenConverter;
    }
}
